package com.dcd.controller;

import com.dcd.pojo.*;
import com.dcd.service.Car_modelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/Car_ModelController")
public class Car_modelController {

    @Autowired
    private Car_modelService ms;

    /**
     * 查询所有车型
     * @param car_series_id 车系id
     * @return
     */
    @RequestMapping("/modelList/{car_series_id}")
    public List<Car_model> modelList(@PathVariable int car_series_id){
        return ms.modelList(car_series_id);
    }

    /**
     * 根据车型id查询亮点配置
     * @param car_model_id 车型id
     * @return
     */
    @RequestMapping("/highlights_configList/{car_model_id}")
    public List<Highlights_configuration> highlights_configList(@PathVariable int car_model_id){
        return ms.highlights_configList(car_model_id);
    }

    /**
     * 按车型id查询详细配置
     * @param car_model_id
     * @return
     */
    @RequestMapping("/select_car_model_ById/{car_model_id}")
    public Car_model select_car_model_ById(@PathVariable int car_model_id){
        return ms.select_car_model_ById(car_model_id);
    }

    /**
     * 车型首页中的热门咨询
     * @param car_model_id 车型id
     * @return
     */
    @RequestMapping("/select_information/{car_model_id}")
    public List<Information> select_information(@PathVariable int car_model_id){
        return ms.select_information(car_model_id);
    }

    /**
     * 根据车名查询车系
     * @param brand_id 车名称id
     * @return
     */
    @RequestMapping("/select_Car_series/{brand_id}")
    public List<Car_series> select_Car_series(@PathVariable int brand_id){
        return ms.select_Car_series(brand_id);
    }

    /**
     * 查询车型页面图片内饰， 外观，空间
     * @param car_model_images_type_id 大图类型id
     * @param brand_id 车系id
     * @return
     */
    @RequestMapping("/selectCar_model_images/{car_model_images_type_id}/{brand_id}")
    public Car_model_images selectCar_model_images(@PathVariable int car_model_images_type_id, @PathVariable int brand_id){
        return ms.selectCar_model_images(car_model_images_type_id,brand_id);
    }

    /**
     * 获取亮点配置图片数量
     * @param car_model_id  车型id
     * @return
     */
    @RequestMapping("/getConfigImgCount/{car_model_id}")
    public Highlights_configuration getConfigImgCount(@PathVariable int car_model_id){
        return ms.getConfigImgCount(car_model_id);
    }

    /**
     * 根据id查询购车计算
     * @param car_model_id  车型id
     * @param car_series_id 车系id
     * @return
     */
    @RequestMapping("/select_car_purchase_calculation/{car_series_id}/{car_model_id}")
    public Map<String,Object> select_car_purchase_calculation(@PathVariable int car_series_id,@PathVariable int car_model_id){
        Map<String,Object> map = new HashMap<>();
        map.put("purchase_calculation",ms.select_car_purchase_calculation(car_model_id));
        map.put("modelList",ms.modelList(car_series_id));
        return map;
    }

    /**
     * 根据品牌id或者车系id或者车型id查询选车当前位置（当前位置：选车->本田->雅阁）
     * @param brand_id   //品牌id
     * @param car_series_id  //车系id
     * @param car_model_id  //车型id
     * @return
     */
    @RequestMapping("/selectBy_brand_series_model_Id/{brand_id}/{car_series_id}/{car_model_id}")
    public Car_series selectBy_brand_series_model_Id(@PathVariable int brand_id,@PathVariable int car_series_id,@PathVariable int car_model_id){
        return ms.selectBy_brand_series_model_Id(brand_id,car_series_id,car_model_id);
    }


}
